<?php
require(dirname(__FILE__) .'/check.php');
$skin->CheckIframe();



/* **** 版权所有 ****

 程序开发：网钛科技
 网钛CMS官网：http://otcms.com
 网钛IDC官网：http://idccms.com
 ＱＱ：877873666
 微信：tudougeaini
 邮箱：877873666@qq.com

 **** 版权所有 **** */


//打开用户表，并检测用户是否登录
$MB->Open('','login');

$skin->WebTop();

$MB->IsSecMenuRight('alertBack',265,$dataType);


echo('
<script language="javascript" type="text/javascript" src="js/inc/list.js?v='. OT_VERSION .'"></script>
<script language="javascript" type="text/javascript" src="js/moneyRecord.js?v='. OT_VERSION .'"></script>
');


switch ($mudi){
	case 'manage':
		manage();
		break;

	case 'userManage':
		UserManage();
		break;

	case 'show':
		show();
		break;

	case 'export':
		export();
		break;

	case 'delManage':
		DelManage();
		break;

	case 'miniRefer':
		MiniRefer();
		break;

	default:
		die('err');
}

$skin->WebBottom();

$MB->Close();
$DB->Close();





// 会员进出账列表
function manage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$refUsername= OT::GetRegExpStr('refUsername','sql');
	$refRealname= OT::GetRegExpStr('refRealname','sql');
	$refDate1	= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2	= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }

	$SQLstr='select * from '. OT_dbPref .'users where (1=1)';

	if ($refUsername != ''){ $SQLstr .= " and UE_username like '%". $refUsername ."%'";}
	if ($refRealname != ''){ $SQLstr .= " and UE_realname like '%". $refRealname ."%'";}
	if ($refDate1 != ''){ $SQLstr .= ' and UE_time>='. $DB->ForTime($refDate1);}
	if ($refDate2 != ''){ $SQLstr .= ' and UE_time<='. $DB->ForTime(TimeDate::Add('d',1,$refDate2));}
	
	$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'username|mail|phone|qq|state|regIP|loginTime|time', 'time');
	$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'会员查询');
		echo('
		<form id="refForm" name="refForm" method="get" action="">
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />

		<table width="98%" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td width="31%">
				&ensp;&ensp;&ensp;&ensp;用户名：
				<input type="text" name="refUsername" size="12" value="'. $refUsername .'" />
			</td>
			<td width="29%">
				真实姓名：<input type="text" name="refRealname" size="16" value="'. $refRealname .'" />
			</td>
			<td>
				&ensp;&ensp;注册日期：<input type="text" name="refDate1" size="10" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
				至&ensp;<input type="text" name="refDate2" size="10" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
		</tr>
		<tr>
			<td align="center" style="padding-top:20px" colspan="3">
				<input type="image" src="'. AdmTpl::ImgSrc('button_refer') .'" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&nohrefStr=close&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer" alt="" />
			</td>
		</tr>
		</table>
		</form>
		');
	$skin->TableBottom();

	echo('<br />');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'会员列表');
	$skin->TableItemTitle('5%,16%,16%,15%,15%,10%','序号,'. $skin->ShowArrow('用户名','username',$orderName,$orderSort) .','. $skin->ShowArrow('真实姓名','realname',$orderName,$orderSort) .','. $skin->ShowArrow('累计消费','payMoney',$orderName,$orderSort) .','. $skin->ShowArrow('账户余额','money',$orderName,$orderSort) .',进出账');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr .' order by UE_'. $orderName .' '. $orderSort,$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd3">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }

			echo('
			<tr '. $bgcolor .' id="data'. $showRow[$i]['UE_ID'] .'">
				<td align="center">'. $number .'</td>
				<td align="center">'. $showRow[$i]['UE_username'] . AdmArea::UserInfoImg($showRow[$i]['UE_ID']) .'</td>
				<td align="center">'. $showRow[$i]['UE_realname'] .'</td>
				<td align="right" style="padding-right:8px;">'. PayInfo::RemMoney($showRow[$i]['UE_payMoney']) .'</td>
				<td align="right" style="padding-right:8px;">'. PayInfo::RemMoney($showRow[$i]['UE_money']) .'</td>
				<td align="center">
					<img src="images/img_db.gif" style="cursor:pointer" onclick=\'var a=window.open("?mudi=userManage&nohrefStr=close&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&userID='. $showRow[$i]['UE_ID'] .'","","top=50,left=150,width=770,height=500,menubar=no,scrollbars=yes,status=no,resizable=yes")\' alt="" />
				</td>
			</tr>
			');
		$number ++;
		}
		echo('</tbody>');
	}
	unset($showRow);

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);
}



// 用户财务加减
function UserManage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$userID = OT::GetInt('userID');
	$dataTypeCN = '财务';

	$userexe=$DB->query('select UE_ID,UE_username,UE_realname,UE_money,UE_moneyGive,UE_payMoney from '. OT_dbPref .'users where UE_ID='. $userID);
		if (! $row = $userexe->fetch()){ JS::AlertCloseEnd('该会员不存在.'); }
	$UE_username = $row['UE_username'];

	echo('
	<script language="javascript" type="text/javascript">document.title="会员财务明细";</script>

	<table style="width:750px;" align="center" cellpadding="0" cellspacing="0" border="0" summary=""><tr><td>
	');

	$skin->TableTop('share_person.gif','','会员财务信息');
		echo('
		<table style="width:99%;" align="center" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td style="width:33%;">
				&ensp;&ensp;用户名：'. $UE_username .'
			</td>
			<td style="width:33%;">
				真实姓名：'. $row['UE_realname'] .'
			</td>
			<td style="width:33%;">
			</td>
		</tr>
		<tr>
			<td>
				账户余额：'. OT::NumFormat($row['UE_money']) .' 元'. ($row['UE_moneyGive'] > 0 ? '（含赠送额：'. OT::NumFormat($row['UE_moneyGive']) .' 元）' : '') .'
			</td>
			<td>
				累计消费：'. OT::NumFormat($row['UE_payMoney']) .' 元
			</td>
			<td>
				其中充值金额：'. OT::NumFormat($DB->GetOne('select sum(MR_money) from '. OT_dbPref .'moneyRecord where MR_userID='. $userID .' and MR_isGive=0 and MR_money>0')) .' 元
			</td>
		</tr>
		</table>
		');
	$skin->TableBottom();

	unset($userexe);

	echo('
	</td></tr></table>

	<br />

	<table width="750" align="center" cellpadding="0" cellspacing="0" border="0" summary=""><tr><td>
	');

	$skin->TableTop('share_refer.gif','','添加/修改'. $dataTypeCN);
		echo('
		<form id="dealForm" name="dealForm" method="post" action="moneyRecord_deal.php?mudi=addOrRev" onsubmit="return CheckForm()">
		<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
		<input type="hidden" id="dataMudi" name="dataMudi" value="add" />
		<input type="hidden" id="dataID" name="dataID" value="" />
		<input type="hidden" id="userID" name="userID" value="'. $userID .'" />
		<input type="hidden" id="username" name="username" value="'. $UE_username .'" />
		<table style="width:99%;" align="center" cellpadding="0" cellspacing="0" summary="" class="padd5td">
		<tr>
			<td align="right">
				<span class="font2_2">*</span>金额类别：
			</td>
			<td>
				<label><input type="radio" id="mode0" name="mode" value="0" onclick="MoneyMode()" checked="checked" />无</label>&ensp;&ensp;
				<label><input type="radio" id="mode1" name="mode" value="1" onclick="MoneyMode()" />进账(+)</label>&ensp;&ensp;
				<label><input type="radio" id="mode2" name="mode" value="2" onclick="MoneyMode()" />出账(-)</label>&ensp;&ensp;
				&ensp;&ensp;<span id="moneyK" style="display:none;"><span class="font2_2">*</span>金额：<input type="text" id="money" name="money" size="7" onkeyup="this.value=FiltDecimal(this.value)" />&ensp;元</span>
			</td>
		</tr>
		<tr id="xiaofeiBox" style="display:none;">
			<td class="font1_2" align="right">
				<span class="font2_2">*</span>属于消费：
			</td>
			<td>
				<label><input type="radio" name="isXiaofei" value="0" checked="checked" />否</label>&ensp;&ensp;
				<label><input type="radio" name="isXiaofei" value="1" />是</label>&ensp;&ensp;
				<span class="font2_2">(选择“是”，会把这笔同时记录到消费金额里)</span>
			</td>
		</tr>
		<tr id="giveBox" style="display:none;">
			<td class="font1_2" align="right">
				<span class="font2_2">*</span>记为赠送：
			</td>
			<td>
				<label><input type="radio" id="isGive0" name="isGive" value="0" checked="checked" />否</label>&ensp;&ensp;
				<label><input type="radio" id="isGive1" name="isGive" value="1" />是</label>&ensp;&ensp;
				<span class="font2_2">(赠送的、没收钱的请选择“是”，否则选“否”)</span>
			</td>
		</tr>
		<tr>
			<td align="right" valign="top" style="padding-top:6px;">
				<span class="font2_2">*</span>备注：
			</td>
			<td>
				<textarea type="text" id="note" name="note" cols="48" rows="3" ></textarea>
				<select onchange="if (this.value!=\'\'){$id(\'note\').value = this.value;}">
					<option value="">候选项</option>
					'. Info::TypeOptionList('moneyNote', '在【IDC设置】-【不扣款说明管理】里设置候选项') .'
				</select>
				<div id="alertStr" class="font2_2" style="padding:5px; line-height:1.2;"></div>
			</td>
		</tr>
		<tr>
			<td align="center" style="padding-top:8px;" colspan="2">
				<input type="image" id="subButton" name="subButton" src="'. AdmTpl::ImgSrc('button_add') .'" />
				&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" style="cursor:pointer" onclick=\'if(confirm("你确定重置")==true){document.location.href="?mudi='. $mudi .'&nohrefStr=close&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&userID='. $userID .'";}\' alt="" />
			</td>
		</tr>
		</table>
		</form>
		');
	$skin->TableBottom();

	echo('
	</td></tr></table>

	<br />

	<table style="width:750px;" align="center" cellpadding="0" cellspacing="0" border="0" summary=""><tr><td>
	<form id="listForm" name="listForm" method="post" action="">
	<script language="javascript" type="text/javascript">document.write (\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
	<input type="hidden" name="dataType" value="'. $dataType .'" />
	<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
	');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'列表');
	$skin->TableItemTitle('4%,6%,9%,10%,25%,11%,6%,7%,11%,11%','<input type="checkbox" id="selAll" name="selAll" onclick="CheckBoxAll()" />,序号,金额,用户余额,备注,添加时间,前台,状态,操作员,详细　修改<!-- 　删除 -->');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit('select * from '. OT_dbPref .'moneyRecord where MR_userID='. $userID .' order by MR_time DESC,MR_ID DESC',$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('<tbody class="tabBody padd3">');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }

			echo('
			<tr '. $bgcolor .' id="data'. $showRow[$i]['MR_ID'] .'">
				<td align="center" class="selCheckbox"><input type="checkbox" name="selDataID[]" value="'. $showRow[$i]['MR_ID'] .'" /></td>
				<td align="center">'. $number .'</td>
				<td align="right" style="padding-right:8px;">
					'. PayInfo::ColorNum($showRow[$i]['MR_money'],$showRow[$i]['MR_remMoney']) .'
					<div>'. ($showRow[$i]['MR_isGive']==1 ? '<span style="color:red;">[赠送]</span>' : '') .'</div>
				</td>
				<td align="right" style="padding-right:8px;">'. PayInfo::RemMoney($showRow[$i]['MR_remMoney'],2) .'</td>
				<td align="center">'. $showRow[$i]['MR_note'] .'</td>
				<td align="center">'. $showRow[$i]['MR_time'] .'</td>
				<td align="center">'. Adm::SwitchBtn('moneyRecord',$showRow[$i]['MR_ID'],$showRow[$i]['MR_userState'],'userState','state') .'</td>
				<td align="center">'. Adm::SwitchBtn('moneyRecord',$showRow[$i]['MR_ID'],$showRow[$i]['MR_state'],'state','moneyState') .'</td>
				<td align="center" title="操作员ID：'. $showRow[$i]['MR_adminID'] .'">'. $showRow[$i]['MR_bank'] .'<div style="color:#bbb;margin-top:6px;">'. $showRow[$i]['MR_adminName'] .'</div></td>
				<td align="center">
					<img src="images/img_det.gif" style="cursor:pointer" onclick=\'var a=window.open("?mudi=show&nohrefStr=close&dataID='. $showRow[$i]['MR_ID'] .'","","top=150,left=250,width=480,height=280,menubar=no,scrollbars=yes,status=no,resizable=yes")\' alt="" />
					&ensp;
					<img src="images/img_rev.gif" style="cursor:pointer" onclick=\'DataDeal.location.href="moneyRecord_deal.php?mudi=send&dataID='. $showRow[$i]['MR_ID'] .'&userID='. $userID .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' alt="" />
					<!-- &ensp;&ensp;
					<img src="images/img_del.gif" style="cursor:pointer" onclick=\'if(confirm("你确定要删除？")==true){DataDeal.location.href="moneyRecord_deal.php?mudi=del&dataID='. $showRow[$i]['MR_ID'] .'&userID='. $userID .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&theme='. urlencode($UE_username) .'"}\' alt="" /> -->
				</td>
			</tr>
			');
		$number ++;
		}
		echo('
		</tbody>
		<tr class="tabColorB padd5">
			<td align="left" colspan="20">
				<input type="button" value="全选" class="tabBottomBtn allSel" onclick="AllSelBox()" />
				<input type="button" value="反选" class="tabBottomBtn revSel" onclick="RevSelBox()" />
				&ensp;&ensp;
				<select id="moreSetTo" name="moreSetTo" onchange="MoreSetTo()" style="width:150px;">
					<option value="">批量设置成...</option>
					<option value="state1" style="color:#0066CC;">状态：有效</option>
					<option value="state0" style="color:red;">状态：作废</option>
					<option value="userState1" style="color:#0066CC;">前台：显示</option>
					<option value="userState0" style="color:red;">前台：隐藏</option>
				</select>
				<input type="hidden" id="moreSetToCN" name="moreSetToCN" value="" />
			</td>
		</tr>
		');
	}
	unset($showrec);

	echo('</form>');

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);

	echo('
	</td></tr></table>
	');
}



// 详细
function show(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN;

	$dataID = OT::GetInt2( OT::ParaArr('id') );

	$showexe=$DB->query('select * from '. OT_dbPref .'moneyRecord where MR_ID='. $dataID);
		if (! $row = $showexe->fetch()){
			JS::AlertCloseEnd('指定ID错误.');
		}

	echo('
	<script language="javascript" type="text/javascript">document.title="'. $dataTypeCN .'财务详细信息";</script>

	<table style="width:450px;" align="center" cellpadding="0" cellspacing="0" border="0" summary=""><tr><td>
	');

	$skin->TableTop2('share_list.gif','',''. $dataTypeCN .'财务详细信息');
		echo('
		<tbody class="padd5td">
		<tr>
			<td style="width:100px;" align="right">添加时间：</td>
			<td>'. $row['MR_time'] .'</td>
		</tr>
		<tr>
			<td align="right">订单号：</td>
			<td>'. $row['MR_orderId'] .'</td>
		</tr>
		<tr>
			<td align="right">项目名称：</td>
			<td>'. $row['MR_dataName'] .'</td>
		</tr>
		<tr>
			<td align="right">用户名：</td>
			<td>'. $row['MR_username'] . AdmArea::UserInfoImg($row['MR_userID']) .'</td>
		</tr>
		<tr>
			<td align="right">类型：</td>
			<td>'. PayInfo::RecordTypeCN($row['MR_type']) . (strlen(''. $row['MR_type2']) > 0 ? '&ensp;<span>（ '. $row['MR_type2'] .' ）</span>' : '') .'</td>
		</tr>
		<tr>
			<td align="right">金额：</td>
			<td>'. OT::NumFormat($row['MR_money']) .'</td>
		</tr>
		<tr>
			<td align="right">用户余额：</td>
			<td>'. PayInfo::RemMoney($row['MR_remMoney']) .'</td>
		</tr>
		<tr>
			<td align="right" valign="top">备注：</td>
			<td>'. $row['MR_note'] .'</td>
		</tr>
		<tr>
			<td align="right">来源：</td>
			<td>'. $row['MR_bank'] .'</td>
		</tr>
		<tr>
			<td align="right">状态：</td>
			<td>'. Adm::SwitchBtn('moneyRecord',$row['MR_ID'],$row['MR_state'],'state','moneyState') .'</td>
		</tr>
		<tr>
			<td align="right">数据修改：</td>
			<td>
				<form method="post" id="noteForm" name="noteForm" action="moneyRecord_deal.php?mudi=revData" onsubmit="return CheckShowForm()">
				<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'">\')</script>
				<input type="hidden" name="dataType" value="'. $dataType .'" />
				<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
				<input type="hidden" name="dataID" value="'. $dataID .'" />
				<table cellpadding="0" cellspacing="0">
				<tr>
					<td style="padding:3px;">
						成本：<input type="text" id="cost" name="cost" size="22" style="width:45px;" value="'. floatval($row['MR_cost']) .'" />
					</td>
					<td style="padding:3px;padding-left:12px;">
						利润：<input type="text" id="gain" name="gain" size="22" style="width:45px;" value="'. floatval($row['MR_gain']) .'" />
					</td>
					<td style="padding:3px;padding-left:12px;">
						<input type="submit" value="保 存" style="height:25px;" />
					</td>
				</tr>
				</table>
				</form>
			</td>
		</tr>
		</tbody>
		<tr class="padd5td">
			<td align="right">管理员：</td>
			<td>'. Adm::AdminName($row['MR_adminID'],$row['MR_adminName']) . ($row['MR_adminID']>0 ? '&ensp;&ensp;（ID：'. $row['MR_adminID'] .'）' : '') .'<!-- </td></tr> -->
		');
	$skin->TableBottom();

	echo('</td></tr></table>');
}



// 进出账不平衡纠正、统计和导出
function export(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$showPageCount,$showCount,$memberexe;

	$dataMode		= OT::GetStr('dataMode');
	$dataModeStr	= OT::GetStr('dataModeStr');

	$refType		= OT::GetRegExpStr('refType','sql');
	$refType2		= OT::GetRegExpStr('refType2','sql');
	$refUsername	= OT::GetRegExpStr('refUsername','sql');
	$refRealname	= OT::GetRegExpStr('refRealname','sql');
	$refState		= OT::GetInt('refState',-1);
	$refNote		= OT::GetRegExpStr('refNote','sql');
	$refBank		= OT::GetRegExpStr('refBank','sql');
	$refAdminName	= OT::GetRegExpStr('refAdminName','sql');
	$refMoney1		= OT::GetFloat('refMoney1');
	$refMoney2		= OT::GetFloat('refMoney2');
	$refDate1		= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2		= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }	// else{ $refDate2=TimeDate::Add('d',1,$refDate2); }
	/* $refAdminName	= OT::Get('refAdminName');
		if (! is_array($refAdminName)){ $refAdminName = array(); } */

	$refNum	= $refUserNum = $refDateNum = 0;
	$mtWhereStr = $statiSqlStr = '';
	$SQLstr = 'select MR_ID,MR_adminID,MR_adminName,MR_isGive,MR_time,MR_type,MR_type2,MR_money,MR_remMoney,MR_cost,MR_gain,MR_userID,MR_username,MR_bank,MR_note,MR_state,MR_agentUserID,MR_agentUsername from '. OT_dbPref .'moneyRecord where (1=1)';

	if ($refType != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_type='. $DB->ForStr($refType);
		$statiSqlStr .= ' and MR_type='. $DB->ForStr($refType);
	}
	if ($refType2 != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_type2 like "%'. $refType2 .'%"';
		$statiSqlStr .= ' and MR_type2 like "%'. $refType2 .'%"';
	}
	if ($refUsername != ''){ 
		$refNum ++;
		$refUserNum ++;
		$SQLstr .= ' and MR_username like "%'. $refUsername .'%"';
		$statiSqlStr .= ' and MR_username like "%'. $refUsername .'%"';
	}
/*	if ($refRealname != ''){ 
		$refNum ++;
		$refUserNum ++;
		$SQLstr .= ' and UE_realname like "%'. $refRealname .'%"';
		$statiSqlStr .= ' and UE_realname like "%'. $refRealname .'%"';
	} */
	if ($refState >= 0){
		$refNum ++;
		$SQLstr .= ' and MR_state='. $refState;
		$statiSqlStr .= ' and MR_state='. $refState;
	}
	if ($refMoney1 > 0){
		$refNum ++;
		$SQLstr .= ' and MR_money>='. $refMoney1;
		$statiSqlStr .= ' and MR_money>='. $refMoney1;
	}
	if ($refMoney2 > 0){
		$refNum ++;
		$SQLstr .= ' and MR_money<='. $refMoney2;
		$statiSqlStr .= ' and MR_money<='. $refMoney2;
	}
	if ($refNote != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_note like "%'. $refNote .'%"';
		$statiSqlStr .= ' and MR_note like "%'. $refNote .'%"';
	}
	if ($refBank != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_bank like "%'. $refBank .'%"';
		$statiSqlStr .= ' and MR_bank like "%'. $refBank .'%"';
	}
	if ($refAdminName != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_adminNote like "%'. $refAdminName .'%"';
		$statiSqlStr .= ' and MR_adminNote like "%'. $refAdminName .'%"';
	}
	if ($refDate1 != ''){ 
		$refNum ++;
		$refDateNum ++;
		$mtWhereStr .= ' or MT_time='. $DB->ForTime($refDate1);
		$SQLstr .= ' and MR_time>='. $DB->ForTime($refDate1);
		$statiSqlStr .= ' and MR_time>='. $DB->ForTime($refDate1);
	}
	if ($refDate2 != ''){ 
		$refNum ++;
		$refDateNum ++;
		$mtWhereStr .= ' or MT_time='. $DB->ForTime($refDate2);
		$SQLstr .= ' and MR_time<='. $DB->ForTime($refDate2);
		$statiSqlStr .= ' and MR_time<='. $DB->ForTime($refDate2);
	}
/*
	if ($refAdminName != ''){ 
		$refNum ++;
		$SQLstr .= ' and MR_adminName like "%'. $refAdminName .'%"';
	}
	if (count($adminNameNewArr)>0){
		$refNum ++;
		$SQLstr .= ' and MR_adminName in ('. $adminNameSelStr .')';
	}
*/


	$todayDate	= TimeDate::Get('date');
	$month1		= TimeDate::Get('Y-m') .'-01';
	$userMoney	= floatval($DB->GetOne('select sum(UE_money) from '. OT_dbPref .'users'));
	$payMoney	= floatval($DB->GetOne('select sum(UE_payMoney) from '. OT_dbPref .'users'));

	$sumNum = 0;
	$sumOptionStr = '';
	/*
	$sumexe = $DB->query('select MT_ID,MT_time,MT_date,MT_remMoney from '. OT_dbPref .'moneyTime order by MT_time DESC limit 180');
		while ($row = $sumexe->fetch()){
			if ($row['MT_remMoney'] == -9){
				$sumOptionStr .= '<option value="">【不平衡纠正】</option>';
			}elseif ($row['MT_remMoney'] == -8){
				$sumOptionStr .= '<option value="">【标记平衡】</option>';
			}else{
				$sumNum ++;
				if ($sumNum == 2){
					// if ($refNum == 0){
					//	$refDate1 = $row['MT_time'];
					//	$refNum ++;
					//	$SQLstr .= ' and MR.MR_time>='. $DB->ForTime($refDate1);
					//	$statiSqlStr .= ' and MR.MR_time>='. $DB->ForTime($refDate1);
					//}
				}
				$sumOptionStr .= '<option value="'. $row['MT_time'] .'">'. $row['MT_time'] .' '. DayDiffCN($row['MT_date'],$todayDate) .'</option>';
			}
		}
	unset($sumexe);
	*/


	$umStr1 = $umStr2 = $umTime2 = $todayMoneyTime = '';
	$umRem1 = $umRem2 = $todayMoney = 0;
	/*
	$mtexe = $DB->query('select MT_time,MT_date,MT_remMoney from '. OT_dbPref .'moneyTime where MT_date='. $DB->ForTime($todayDate) .''. $mtWhereStr .' limit 2');
		while ($row = $mtexe->fetch()){
			if (strtotime($row['MT_date']) == strtotime($todayDate)){
				$todayMoneyTime = $row['MT_time'];
				$todayMoney = floatval($row['MT_remMoney']);
				if (strtotime($refDate2) == strtotime($row['MT_time'])){
					$umTime2 = $row['MT_time'];
					$umStr2 = DayDiffCN($row['MT_date'],$todayDate);
					$umRem2 = floatval($row['MT_remMoney']);
				}
			}elseif (strtotime($refDate1) == strtotime($row['MT_time'])){
				$umStr1 = DayDiffCN($row['MT_date'],$todayDate);
				$umRem1 = floatval($row['MT_remMoney']);
			}elseif (strtotime($refDate2) == strtotime($row['MT_time'])){
				$umTime2 = $row['MT_time'];
				$umStr2 = DayDiffCN($row['MT_date'],$todayDate);
				$umRem2 = floatval($row['MT_remMoney']);
			}
		}
	unset($mtexe);

	if (OT::FloatCmp($userMoney,$todayMoney) != 0){
		$recordexe = $DB->query('select MT_ID from '. OT_dbPref .'moneyTime where MT_date='. $DB->ForTime($todayDate));
			if (! $row = $recordexe->fetch()){
				$DB->InsertParam('moneyTime',array(
					'MT_time'		=> TimeDate::Get(),
					'MT_date'		=> $todayDate,
					'MT_remMoney'	=> $userMoney,
					'MT_payMoney'	=> $payMoney
					));
			}else{
				$DB->UpdateParam('moneyTime',array(
					'MT_time'		=> TimeDate::Get(),
					'MT_remMoney'	=> $userMoney,
					'MT_payMoney'	=> $payMoney
					),'MT_ID='. $row['MT_ID']);
			}
		unset($recordexe);
		$todayMoney = $userMoney;
	}
	*/
	if ($refDate2 == ''){
		$umStr2 = '(今天)';
		$umTime2 = $todayMoneyTime;
		$umRem2 = $todayMoney;
	}

	$SQLstr .= ' order by MR_time DESC,MR_ID DESC';

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'查询/导出');
		echo('
		<form id="refForm" name="refForm" method="get" action="" onsubmit="return CheckExportForm()">
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />
		<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />

		<table width="100%" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td width="31%">
				类型：<select id="refType" name="refType">
					<option value=""></option>
					');
					$typeArr = PayInfo::RecordTypeArr();
					foreach ($typeArr as $key => $val){
						echo('<option value="'. $key .'" '. Is::Selected($refType,$key) .'>'. $val .'</option>');
					}
					echo('
					</select>
				&ensp;&ensp;&ensp;类型2：<input type="text" name="refType2" size="16" style="width:80px;" value="'. $refType2 .'" />
			</td>
			<td width="23%">
				&ensp;&ensp;&ensp;&ensp;用户名：<input type="text" name="refUsername" size="16" value="'. $refUsername .'" />
			</td>
			<td width="46%">
				<!-- &ensp;&ensp;真实姓名：<input type="text" name="refRealname" size="12" value="'. $refRealname .'" /> -->
				&ensp;&ensp;金额：<input type="text" name="refMoney1" size="18" style="width:50px;" value="'. ($refMoney1>0?$refMoney1:'') .'" />
					- <input type="text" name="refMoney2" size="18" style="width:50px;" value="'. ($refMoney2>0?$refMoney2:'') .'" />
				&ensp;&ensp;&ensp;&ensp;状态：<select id="refState" name="refState">
					<option value=""></option>
					<option value="1" '. Is::Selected($refState,1) .'>有效</option>
					<option value="0" '. Is::Selected($refState,0) .'>作废</option>
					</select>
			</td>
		</tr>
		<tr>
			<td>
				来源：<input type="text" name="refBank" size="16" style="width:97px;" value="'. $refBank .'" />
				&ensp;&ensp;操作员：<input type="text" name="refAdminName" size="16" style="width:80px;" value="'. $refAdminName .'" />
			</td>
			<td>
				&ensp;&ensp;&ensp;&ensp;&ensp;&ensp;备注：<input type="text" id="refNote" name="refNote" size="16" value="'. $refNote .'" />
			</td>
			<td colspan="1">
				&ensp;&ensp;发生时间：'.
					'<!-- <select id="selDate1" name="selDate1" style="width:169px;" onchange=\'$id("refDate1").value=this.value;this.value="";\'>'.
						'<option value="" style="color:red;">会员余额历史记录时间</option>'. $sumOptionStr .
					'</select> style="position:relative;" position: absolute; left:-169px; -->'.
					'<span>'.
						'<input type="text" id="refDate1" name="refDate1" style="width:145px;" onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd HH:mm:ss"})\' value="'. $refDate1 .'" />'.
					'</span>&ensp;'.
				'&ensp;至&ensp;'.
					'<!-- <select id="selDate2" name="selDate2" style="width:169px;" onchange=\'$id("refDate2").value=this.value;this.value="";\'>'.
						'<option value="" style="color:red;">会员余额历史记录时间</option>'. $sumOptionStr .
					'</select> style="position:relative;" position: absolute; left:-169px; -->'.
					'<span>'.
						'<input type="text" id="refDate2" name="refDate2" style="width:145px;" onfocus=\'WdatePicker({dateFmt:"yyyy-MM-dd HH:mm:ss"})\' value="'. $refDate2 .'" />'.
					'</span>
			</td>
		</tr>
		<tr>
			<td colspan="2" style="display:none;">
				系统操作者：
				<a href="#" onclick="AdminNameAllSel();return false;" class="font3_2">[全选]</a>
				<a href="#" onclick="AdminNameNoSel();return false;" class="font3_2">[全不选]</a>
				<a href="#" onclick="AdminNameRevSel();return false;" class="font3_2">[反选]</a>
				&ensp;&ensp;&ensp;&ensp;<span class="font2_2">(全不选 与 全选 效果一致)</span>

				<table width="100%" cellpadding="0" cellspacing="0"><tr><td style="padding-left:75px;">
				');
/*					foreach ($adminNameArr as $value){
				echo('
				<div style="float:left; width:16.64%;"><label><input type="checkbox" name="refAdminName[]" value="'. $value .'" '. Is::InstrChecked($adminNameSelStr,'['. $value .']') .' />'. $value .'</label></div>
				');
					}*/
				echo('
				</td></tr></table>
			</td>
		</tr>
		<tr>
			<td align="center" style="padding-top:20px" colspan="3">
				<img src="'. AdmTpl::ImgSrc('button_refer') .'" style="cursor:pointer;" onclick=\'RefFormSubmit("refer");\' />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer" alt="" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_excel') .'" style="cursor:pointer;" onclick=\'RefFormSubmit("export");\' />
			</td>
		</tr>
		<tr>
			<td align="left" style="padding-top:20px;line-height:1.3;" colspan="3">
				快捷：
				<a href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&mudi='. $mudi .'&mudi='. $mudi .'&refDate1='. $todayDate .' 00:00:00&refDate2='. $todayDate .' 23:59:59" class="font2_1">[今日财务]</a>
				&ensp;
				<a href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&mudi='. $mudi .'&mudi='. $mudi .'&refDate1='. TimeDate::Add('d',-7,$todayDate) .' 00:00:00&refDate2='. $todayDate .' 23:59:59" class="font2_1">[一周财务]</a>
				<a href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&mudi='. $mudi .'&mudi='. $mudi .'&refDate1='. $month1 .' 00:00:00&refDate2='. TimeDate::Add('s',-1,TimeDate::Add('m',1,$month1)) .'" class="font2_1">[本月财务]</a>
				<a href="?mudi='. $mudi .'&dataMode='. $dataMode .'&dataModeStr='. $dataModeStr .'&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'&mudi='. $mudi .'&mudi='. $mudi .'&refDate1='. TimeDate::Add('m',-1,$month1) .' 00:00:00&refDate2='. TimeDate::Add('s',-1,$month1) .'" class="font2_1">[上月财务]</a>

				<br /><br />
				<div style="float:right;">
					天数：<input type="text" id="statiMonthNum" name="statiMonthNum" size="20" style="width:35px;" value="30" />
					<input type="button" value="历日金额统计" onclick=\'AjaxGetDealToId("moneyRecord_deal.php?mudi=statiDay&num="+ $id("statiMonthNum").value +"","fullYearBox");WindowHeight(0);setTimeout("WindowHeight(-1);",5000);\' />
					，&ensp;
					年数：<input type="text" id="statiNum" name="statiNum" size="20" style="width:35px;" value="3" />&ensp;&ensp;
					<input type="button" value="历年月金额统计" onclick=\'AjaxGetDealToId("moneyRecord_deal.php?mudi=stati&num="+ $id("statiNum").value +"","fullYearBox");WindowHeight(0);setTimeout("WindowHeight(-1);",5000);\' />
				</div>
				<a href="#" onclick="CheckNoteStr();return false;" class="font3_2">[显示注释说明]</a>
				<div id="noteStr" style="display:none;">
					名词解释：<span class="font2_2">余账</span>：进账 - 出账(消费)；<span class="font2_2">会员差额</span>：后一次会员余额 - 前一次会员余额；<span class="font2_2">对账</span>：如果余账=会员差额，则平衡，否者不平衡；
					<br />
					说明：<br />
					1.每次进入该页面，系统会自动统计目前总会员余额，如有变动自动更新到历史会员余额表中。<br />
					2.查询条件中的[发生时间]，通过手工或弹出的时间表选择的时间，可进行财务统计；通过右侧下拉箭头选择的时间，可进行财务对账。<br />
					3.如果对账不平衡，会出现不平衡更正框，用来查明原因后添加一条不平衡金额的财务信息，来达到财务平衡。对账不平衡时需及时做不平衡更正，不然后期财务信息就算没错也会对账不平衡！
				</div>
			</td>
		</tr>
		</table>
		</form>
		<div id="fullYearBox"></div>
		');
	$skin->TableBottom();

	echo('<br />');

	$skin->TableTop2('share_list.gif','',$dataTypeCN .'列表');
	$skin->TableItemTitle('4%,10%,8%,7%,7%,6%,6%,8%,21%,7%,4%,7%,4%','序号,用户名,类型,交易金额,用户余额,成本,利润,来源,备注,发生时间,状态,操作员,详细');

	$pageCount = $recordCount = 0;
	$pageSize	= $MB->mMbRow['MB_itemNum'];		//每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr,$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd5td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 1){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
			$currMoney	= floatval($showRow[$i]['MR_money']);
			$cost		= floatval($showRow[$i]['MR_cost']);
			$gain		= floatval($showRow[$i]['MR_gain']);
			if ($cost == 0){ $costStr=''; }else{ $costStr=PayInfo::RemMoney($cost); }
			if ($gain == 0){ $gainStr=''; }else{ $gainStr=PayInfo::RemMoney($gain); }
			if (empty($showRow[$i]['UE_username'])){
				$username	= $showRow[$i]['MR_username'];
			}else{
				$username	= $showRow[$i]['UE_username'];
				if ($username != $showRow[$i]['MR_username']){
					$username	.= '<div class="font1_2d" style="text-decoration:line-through;">['. $showRow[$i]['MR_username'] .']</div>';
				}
			}

			echo('
			<tr '. $bgcolor .'>
				<td align="center">'. $number .'</td>
				<td align="center">
					'. $username . AdmArea::UserInfoImg($showRow[$i]['MR_userID']) .'
					'. ($showRow[$i]['MR_agentUserID'] > 0 ? '<div><span style="color:blue;">销售代理：</span>'. $showRow[$i]['MR_agentUsername'] .'</div>' : '') .'
				</td>
				<td align="center" style="line-height:1.6;">'. PayInfo::RecordTypeCN($showRow[$i]['MR_type']) .'<div style="color:#aaa;">'. $showRow[$i]['MR_type2'] .'</div></td>
				<td align="right" style="padding-right:8px;">
					'. PayInfo::ColorNum($showRow[$i]['MR_money'],$showRow[$i]['MR_remMoney']) .'
					'. ($showRow[$i]['MR_isGive']==1 ? '<div style="color:red;">[赠送]</div>' : '') .'
				</td>
				<td align="right" style="padding-right:8px;">'. PayInfo::RemMoney($showRow[$i]['MR_remMoney']) .'</td>
				<td align="right" style="padding-right:8px;">'. $costStr .'</td>
				<td align="right" style="padding-right:8px;">'. $gainStr .'</td>
				<td align="center">'. $showRow[$i]['MR_bank'] .'</td>
				<td align="left">'. $showRow[$i]['MR_note'] .'</td>
				<td align="center">'. $showRow[$i]['MR_time'] .'</td>
				<td align="center">'. Adm::SwitchBtn('moneyRecord',$showRow[$i]['MR_ID'],$showRow[$i]['MR_state'],'state','moneyState') .'</td>
				<td align="center">'. Adm::AdminName($showRow[$i]['MR_adminID'],$showRow[$i]['MR_adminName']) .'</td>
				<td align="center">
					<img src="images/img_det.gif" style="cursor:pointer" onclick=\'OT_OpenMoneyRecordDet('. $showRow[$i]['MR_ID'] .')\' alt="" />
				</td>
			</tr>
			');
			$number ++;
		}
		echo('
		</tbody>
		');
	}
	unset($showRow);

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);

}



// 删除
function DelManage(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN;

	$skin->TableTop('share_refer.gif','',$dataTypeCN .'删除');
		echo('
		<form id="refForm" name="refForm" method="post" action="moneyRecord_deal.php?mudi=delRecord" onsubmit=\'if (confirm("您确定执行？")==false){return false;}\'>
		<script language="javascript" type="text/javascript">document.write(\'<input type="hidden" name="backURL" value="\'+ document.location.href +\'" />\')</script>
		<input type="hidden" name="mudi" value="'. $mudi .'" />
		<input type="hidden" name="dataTypeCN" value="'. $dataTypeCN .'" />
		<input type="hidden" name="dataType" value="'. $dataType .'" />
		<table style="width:400px;" align="center" border="0" cellSpacing="0" cellPadding="0" summary="">
		<tr>
			<td>
				<input type="text" name="refDate" size="12" value="'. TimeDate::Add('m',-3,TimeDate::Get('date')) .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />之前的记录
				&ensp;
				<input type="submit" value="确定删除">
			</td>
			<!-- <td>
				<input type="image" src="'. AdmTpl::ImgSrc('button_del') .'" />
			</td> -->
		</tr>
		</table>
		<br />
		<div class="font2_2">提示：此功能是为了清理陈旧的记录，以减少财务信息量.只能清理3个月之前的财务记录。</div>
		</form>
		');
	$skin->TableBottom();

}



// 迷你查询
function MiniRefer(){
	global $DB,$MB,$skin,$mudi,$dataType,$dataTypeCN,$pageCount,$recordCount;

	$refUsername	= OT::GetRegExpStr('refUsername','sql');
	$refAdminName	= OT::GetRegExpStr('refAdminName','sql');
	$refType		= OT::GetRegExpStr('refType','sql');
	$refType2		= OT::GetRegExpStr('refType2','sql');
	$refVpsName		= OT::GetRegExpStr('refVpsName','sql+.');
	$refState		= OT::GetInt('refState',-1);
	$refDate1		= OT::GetStr('refDate1');
		if (! strtotime($refDate1)){ $refDate1=''; }
	$refDate2		= OT::GetStr('refDate2');
		if (! strtotime($refDate2)){ $refDate2=''; }

	$SQLstr='select * from '. OT_dbPref .'moneyRecord where (1=1)';

	if ($refUsername != ''){ $SQLstr .= " and MR_username like '%". $refUsername ."%'"; }
	if ($refAdminName != ''){ $SQLstr .= " and MR_adminName like '%". $refAdminName ."%'"; }
	if ($refType != ''){ $SQLstr .= " and MR_type='". $refType ."'"; }
	if ($refType2 != ''){ $SQLstr .= " and MR_type2='". $refType2 ."'"; }
	if ($refVpsName != ''){ $SQLstr .= " and MR_dataName like '%". $refVpsName ."%'"; }
	if ($refState >= 0){ $SQLstr .= ' and MR_state='. $refState; }
	if ($refDate1 != ''){ $SQLstr .= " and MR_time>=". $DB->ForTime($refDate1); }
	if ($refDate2 != ''){ $SQLstr .= " and MR_time<=". $DB->ForTime(TimeDate::Add("d",1,$refDate2)); }
	//if (refDate2 != ''){ $SQLstr .= " and MR_time<=". $DB->ForTime($refDate2); }

	$orderName = OT::ListDefVal(OT::GetStr('orderName'), 'username|money|remMoney|type2|dataName|useNum|time', 'time');
	$orderSort = OT::ListDefVal(OT::GetStr('orderSort'), 'ASC', 'DESC');

	echo('
	<script language="javascript" type="text/javascript">document.title="'. $dataTypeCN .'财务信息";</script>
	<table width="98%" align="center" cellpadding="0" cellspacing="0"><tr><td>
	');

	$skin->TableTop('share_refer.gif','','财务信息查询');
		echo('
		<form id="refForm" name="refForm" method="get" action="">
		<input type="hidden" id="mudi" name="mudi" value="'. $mudi .'" />
		<input type="hidden" id="dataType" name="dataType" value="'. $dataType .'" />
		<input type="hidden" id="dataTypeCN" name="dataTypeCN" value="'. $dataTypeCN .'" />
		<input type="hidden" id="nohrefStr" name="nohrefStr" value="'. OT::GetStr('nohrefStr') .'" />

		<table style="width:100%;" align="center" border="0" cellSpacing="0" cellPadding="0" summary="" class="padd5td">
		<tr>
			<td style="width:30%;">
				&ensp;&ensp;用户名：<input type="text" name="refUsername" size="12" value="'. $refUsername .'" />
			</td>
			<td style="width:30%;">
				&ensp;&ensp;&ensp;&ensp;类别：<select name="refType">
					<option value="">&ensp;</option>
					'. (AppHost::Jud() ? '<option value="host" '. Is::Selected($refType,'host') .'>虚拟主机</option>' : '') .'
					<option value="vpsApi" '. Is::Selected($refType,'vpsApi') .'>云服务器</option>
					'. (AppDialing::Jud() ? '<option value="dialing" '. Is::Selected($refType,'dialing') .'>拨号VPS</option>' : '') .'
					'. (AppPptp::Jud() ? '<option value="pptp" '. Is::Selected($refType,'pptp') .'>PPTP</option>' : '') .'
					'. (AppServ::Jud() ? '<option value="serv" '. Is::Selected($refType,'serv') .'>服务器租用</option>' : '') .'
					'. (AppDomain::Jud() ? '<option value="domain" '. Is::Selected($refType,'domain') .'>域名</option>' : '') .'
					<option value="suff" '. Is::Selected($refType,'suff') .'>充值</option>
					<option value="tixian" '. Is::Selected($refType,'tixian') .'>提现</option>
					<option value="moneyPay" '. Is::Selected($refType,'moneyPay') .'>在线支付</option>
				</select>
			</td>
			<td style="width:40%;">
				&ensp;&ensp;&ensp;&ensp;类型：<select name="refType2">
					<option value="">&ensp;</option>
					<option value="开通" '. Is::Selected($refType2,'开通') .'>开通</option>
					<option value="转正" '. Is::Selected($refType2,'转正') .'>转正</option>
					<option value="续费" '. Is::Selected($refType2,'续费') .'>续费</option>
					<option value="升级" '. Is::Selected($refType2,'升级') .'>升级</option>
					<option value="退款" '. Is::Selected($refType2,'退款') .'>退款</option>
				</select>
				&ensp;&ensp;&ensp;&ensp;状态：<select name="refState">
					<option value="-1">&ensp;</option>
					<option value="1" '. Is::Selected($refState,1) .'>正常</option>
					<option value="0" '. Is::Selected($refState,0) .'>作废</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				&ensp;&ensp;操作员：<input type="text" name="refAdminName" size="12" value="'. $refAdminName .'" />
			</td>
			<td>
				机器编码：<input type="text" name="refVpsName" size="12" value="'. $refVpsName .'" />
			</td>
			<td>
				发生日期：<input type="text" name="refDate1" size="10" value="'. $refDate1 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />&ensp;
				至&ensp;<input type="text" name="refDate2" size="10" value="'. $refDate2 .'" onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd\'})" />
			</td>
		</tr>
		<tr>
			<td align="center" style="padding-top:10px;" colspan="3">
				<input type="image" src="'. AdmTpl::ImgSrc('button_refer') .'" />
				&ensp;&ensp;&ensp;&ensp;
				<img src="'. AdmTpl::ImgSrc('button_reset') .'" onclick=\'document.location.href="?mudi='. $mudi .'&nohrefStr=close&dataType='. $dataType .'&dataTypeCN='. urlencode($dataTypeCN) .'"\' style="cursor:pointer" alt="" />
			</td>
		</tr>
		</table>
		</form>
		');
	$skin->TableBottom();

	echo('
	</td></tr></table>

	<br />

	<table width="98%" align="center" cellpadding="0" cellspacing="0"><tr><td>
	');

	$skin->TableTop2('share_list.gif','','财务信息列表');
	$skin->TableItemTitle('6%,11%,9%,9%,10%,10%,9%,26%,10%','序号,'. $skin->ShowArrow('用户名','username',$orderName,$orderSort) .','. $skin->ShowArrow('金额','money',$orderName,$orderSort) .','. $skin->ShowArrow('余额','remMoney',$orderName,$orderSort) .','. $skin->ShowArrow('类型','type2',$orderName,$orderSort) .','. $skin->ShowArrow('操作员','adminName',$orderName,$orderSort) .','. $skin->ShowArrow('机器编码','dataName',$orderName,$orderSort) .',原因,'. $skin->ShowArrow('发生时间','time',$orderName,$orderSort) .'');

	$pageSize	= $MB->mMbRow['MB_itemNum'];		// 每页条数
	$page		= OT::GetInt('page');
	$showRow=$DB->GetLimit($SQLstr .' order by MR_'. $orderName .' '. $orderSort .',MR_ID '. $orderSort,$pageSize,$page);
	if (! $showRow){
		$skin->TableNoData();
	}else{
		$recordCount=$DB->GetRowCount();
		$pageCount=ceil($recordCount/$pageSize);
		if ($page < 1 || $page > $pageCount){$page=1;}

		echo('
		<tbody class="tabBody padd3td">
		');
		$number=1+($page-1)*$pageSize;
		$rowCount = count($showRow);
		for ($i=0; $i<$rowCount; $i++){
			if ($i % 2 == 0){ $bgcolor='class="tabColorTr"'; }else{ $bgcolor=''; }
			if ($showRow[$i]['MR_userID'] > 0){
				$moneyStr = PayInfo::ColorNum($showRow[$i]['MR_money'],$showRow[$i]['MR_remMoney']);
			}else{
				$moneyStr = PayInfo::ColorNum($showRow[$i]['MR_money']);
			}
			echo('
			<tr '. $bgcolor .'>
				<td align="center">'. $number .'</td>
				<td align="center">'. $showRow[$i]['MR_username'] .'</td>
				<td align="center">'. $moneyStr .'</td>
				<td align="center">'. PayInfo::RemMoney($showRow[$i]['MR_remMoney']) .'</td>
				<td align="center">'. $showRow[$i]['MR_type2'] .'</td>
				<td align="center" title="操作员ID：'. $showRow[$i]['MR_adminID'] .'">'. $showRow[$i]['MR_bank'] .'<div style="color:#bbb;margin-top:6px;">'. $showRow[$i]['MR_adminName'] .'</div></td>
				<td align="center">'. $showRow[$i]['MR_dataName'] .'</td>
				<td align="left">'. $showRow[$i]['MR_note'] .'</td>
				<td align="center">'. $showRow[$i]['MR_time'] .'</td>
			</tr>
			');
			$number ++;
		}
		echo('
		</tbody>
		');
	}
	unset($showRow);

	$skin->TableBottom2($pageCount, $pageSize, $recordCount);

	echo('</td></tr></table>');
}



// 距离天数
function DayDiffCN($date1,$date2){
	$diffDay = TimeDate::Diff('d',$date1,$date2);

	if ($diffDay==0){
		return '(今天)';
	}elseif ($diffDay==1){
		return '(昨天)';
	}elseif ($diffDay==2){
		return '(前天)';
	}else{
		return '('. $diffDay .'天前)';
	}
}


// 计算符号
function CalSign($str){
	switch ($str){
		case '大于':
			return '>';

		case '大于等于':
			return '>=';

		case '等于':
			return '=';

		case '小于等于':
			return '<=';

		case '小于':
			return '<';

		default:
			return '';
	}
}

?>